package homeWork.day03;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Random;

/**
 * 生成10个0-100的随机数并存入一个List集合中并输出
 * 之后将集合第3到第6个元素翻转并输出
 * 
 * @author Xiloer
 *
 */
public class Test04 {
    public static void main(String[] args) {
        Random rand = new Random();
        List <Integer> randNums = new ArrayList<>();
        int r;
        while (randNums.size()<10){
            r=rand.nextInt(101);
            randNums.add(r);
        }
        List <Integer> randNums1 = randNums.subList(2,6);
        int max = randNums1.size()-1;
        for (int i =0; i<randNums1.size()/2;i++,max--){
            int change = randNums1.set(i, randNums1.get(max));
            randNums1.set(max,change);
        }
        Iterator<Integer> it = randNums.iterator();
        while (it.hasNext()){
            System.out.print(it.next()+" ");
        }

    }

}
